﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Entities;
using Utility;
using BUS;

public partial class Administrator_doanhnghiep_chitiet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data();
        }
    }

    private void load_data()
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        Tbl_doanhnghiep_Entities dn = Tbl_doanhnghiep_BUS.GetByID(id);
        lit_madoanhnghiep.Text = dn.MaDoanhNghiep;
        lit_tendn.Text = dn.TenDoanhNghiep;
        txt_dc.Text = dn.DiaChi;
        lit_dt.Text = dn.DienThoai;
        hyp_website.Text = dn.WebSite;
        hyp_website.NavigateUrl = "http://" + dn.WebSite;
        img_bando.ImageUrl = "~/Photos/Thumbs/" + dn.Map;
        txt_gioithieu.Text = dn.GioiThieu;
        lit_taikhoan.Text = dn.Taikhoan;
        lit_sodutaikhoan.Text = dn.Sodutaikhoan.ToString();
        load_image();
    }

    private void load_image()
    {
        int id = int.Parse(Request.QueryString["id"]);
        Tbl_ImageDN_Collection imgdn = Tbl_ImageDN_BUS.GetByID(id);
        DataList1.DataSource = imgdn;
        DataList1.DataBind();
    }

    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {

            Tbl_ImageDN_Entities hinh = (Tbl_ImageDN_Entities)e.Item.DataItem;
            Image imgdn = (Image)e.Item.FindControl("imgdn");
            imgdn.ImageUrl = "~/Photos/Thumbs/" + hinh.ImagePath;

        }
    }
}
